package com.ynsj.controller;

import com.ynsj.domain.Sms;
import com.ynsj.model.R;
import com.ynsj.service.SmsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sms")
public class SmsController {

    @Autowired
    private SmsService smsService;

    @PostMapping("/sendTo")
    @ApiOperation("发送短信")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "countryCode",value = "国家代码"),
            @ApiImplicitParam(name = "mobile",value = "手机号"),
            @ApiImplicitParam(name = "templateCode",value = "手机号类型")
    })
    public R sendSms(@RequestBody @Validated Sms sms){
        boolean isOk = smsService.sendSms(sms);
        if (isOk){
            return R.ok("短信发送成功");
        }
        return R.fail("短信发送失败");
    }
}
